///*
// *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
// *
// *  Redistribution and use in source and binary forms, with or without
// *  modification, are permitted provided that the following conditions are met:
// *
// *  Redistributions of source code must retain the above copyright notice,
// *  this list of conditions and the following disclaimer.
// *  Redistributions in binary form must reproduce the above copyright
// *  notice, this list of conditions and the following disclaimer in the
// *  documentation and/or other materials provided with the distribution.
// *  Neither the name of the dreamlu.net developer nor the names of its
// *  contributors may be used to endorse or promote products derived from
// *  this software without specific prior written permission.
// *  Author: Chill 庄骞 (smallchill@163.com)
// */
//package com.plian.system.controller.fr.vehicle;
//
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.baomidou.mybatisplus.core.metadata.IPage;
//import com.plian.Tools.Func;
//import com.plian.Tools.StringPool;
//import com.plian.Tools.base.BaseController;
//import com.plian.Tools.pagedata.PageData;
//import com.plian.system.common.status.CustomCode;
//import com.plian.system.config.Resubmit;
//import com.plian.system.dto.fr.vehicle.VehicleLeaseDTO;
//import com.plian.system.entity.fr.vehicle.VehicleLease;
//import com.plian.system.model.CommonCode;
//import com.plian.system.model.ListResult;
//import com.plian.system.model.ObjResult;
//import com.plian.system.model.R;
//import com.plian.system.mybatis.search.SearchEntity;
//import com.plian.system.mybatis.search.SearchParamEntiy;
//import com.plian.system.mybatis.search.TokenSearch;
//import com.plian.system.mybatis.support.Condition;
//import com.plian.system.mybatis.support.Query;
//import com.plian.system.service.fr.vehicle.IVehicleLeaseService;
//import com.plian.system.vo.fr.vehicle.VehicleLeaseVO;
//import com.plian.system.vo.report.ReportReturnVO;
//import com.plian.system.wrapper.fr.veihicle.VehicleLeaseWrapper;
//import lombok.AllArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.lang.exception.ExceptionUtils;
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import javax.validation.Valid;
//import java.util.List;
//import java.util.Optional;
//
///**
// * 车辆租赁管理 控制器
// *
// * @author jianglei
// * @since 2019-09-29
// */
//@Slf4j
//@RestController
//@RequestMapping("api/vehiclelease")
//@AllArgsConstructor
//public class VehicleLeaseController extends BaseController {
//
//	private IVehicleLeaseService vehicleLeaseService;
//
//	private VehicleLeaseWrapper vehicleLeaseWrapper;
//
//
//    /**
//    * 详情
//    */
//	@PostMapping("/detail")
//	public R<VehicleLeaseVO> detail(@Valid @RequestBody VehicleLease vehicleLease) {
//		VehicleLease detail = vehicleLeaseService.getOne(Condition.getQueryWrapper(vehicleLease));
//		return R.data(vehicleLeaseWrapper.entityToVO(detail));
//	}
//
//	/**
//	* 分页 车辆租赁管理
//	*/
//	@PostMapping("/list")
//	public ListResult<VehicleLeaseVO> list(@RequestBody Query query) {
//
//		List<SearchEntity> entityList = query.getSearch();
//		if (query.getAscs()==null&&query.getDescs()==null){
//			query.setDescs("create_time");
//		}
//
//		QueryWrapper<VehicleLease> queryWrapper = SearchParamEntiy.getQueryWrapper(Condition.getQueryWrapper(new VehicleLease()), entityList);
//		TokenSearch<VehicleLease> tokenSearch = new TokenSearch<>();
//		tokenSearch.addTokenQuery(queryWrapper, query);
//		IPage<VehicleLease> pages = vehicleLeaseService.page(Condition.getPage(query), queryWrapper);
//		List<VehicleLeaseVO> vehicleLeaseVOS  = vehicleLeaseWrapper.entityToVO(pages.getRecords());
//		ListResult<VehicleLeaseVO> listResult = new ListResult<>(CommonCode.SUCCESS);
//		listResult.setList(vehicleLeaseVOS);
//		listResult.setTotal(Long.valueOf(pages.getTotal()).intValue());
//		return listResult;
//	}
//
//
//
//	/**
//	* 新增或修改 车辆租赁管理
//	*/
//	@PostMapping("/submit")
//	@Resubmit(delaySeconds = 0)
//	public R submit(@Valid @RequestBody VehicleLease vehicleLease) {
//
//		if (!(Optional.ofNullable(vehicleLease).isPresent() && Optional.ofNullable(vehicleLease.getStatus()).isPresent()
//				&& vehicleLease.getStatus() == -1)) {
//			String message = vehicleLeaseService.checkSubmit(vehicleLease);
//			if (Optional.ofNullable(message).isPresent()) {
//				return new R(CustomCode.builder().message(message).code(1999).success(false).build());
//			}
//
//			if (vehicleLease.getRentalCompanyId() != null && vehicleLease.getNumberPlate() != null) {
//				message = vehicleLeaseService.checkCarCompany(vehicleLease.getId(), vehicleLease.getRentalCompanyId(), vehicleLease.getNumberPlate());
//			}
//			if (Optional.ofNullable(message).isPresent()) {
//				return new R(CustomCode.builder().message(message).code(1999).success(false).build());
//			}
//		}
//		if(vehicleLease.getDef1()==null || "".equals(vehicleLease.getDef1())){
//			vehicleLease.setDef1("1");
//		}
//		return vehicleLeaseService.submit(vehicleLease, 1)
//				? new R(CommonCode.SUCCESS) : new R(CommonCode.FAIL);
//	}
//
////	/**
////	* 参照 车辆租赁管理
////	*/
////	@GetMapping("/ref")
////    @ApiOperationSupport(order = 4)
////	@ApiOperation(value = "参照 ", notes = "传入vehicleLease")
////	public R<IPage<VehicleLease>> ref(VehicleLease vehicleLease, Query query) {
////	    //TODO 修改参照返回字段,like必须是数据库字段
////        QueryWrapper<VehicleLease> qw=Optional.ofNullable(vehicleLease.getName()).map(
////            s->
////            {
////                String name=vehicleLease.getName();
////                vehicleLease.setName(null);
////                return Condition.getQueryWrapper(vehicleLease).like("name",name);
////            }
////        )
////        .orElse(Condition.getQueryWrapper(vehicleLease));
////        IPage<VehicleLease> pages = vehicleLeaseService.page(Condition.getPage(query),
////            qw.select(f -> Sets.newHashSet("id", "code", "name").contains(f.getProperty())));
////		return R.data(pages);
////	}
//
//
//
//
//
//
//	/**
//	* 删除 车辆租赁管理
//	*/
//	@PostMapping("/remove")
//	public R remove(@RequestBody PageData pd) {
//		List<String> ids = (List<String>)pd.get("ids");
//		return vehicleLeaseService.deleteLogic(Func.toLongList(StringUtils.join(ids, StringPool.COMMA)))
//				? new R(CommonCode.SUCCESS) : new R(CommonCode.FAIL);
//	}
//
//	/**
//	 * 变更 车辆租赁管理
//	 */
//	@PostMapping("/change")
//	public ObjResult change(@Valid @RequestBody VehicleLease vehicleLease) {
//		return vehicleLeaseService.change(vehicleLease);
//	}
//
//	/**
//	 * 宁波市属国有企业长期租赁业务经营保障用车存量情况统计表
//	 */
//	@PostMapping("/leaseStatistics")
//	public ObjResult leaseStatistics(@Valid @RequestBody(required = false) VehicleLeaseDTO vehicleLeaseDTO) {
//		ObjResult objResult;
//		try {
//			ReportReturnVO reportReturnVO = vehicleLeaseService.leaseStatistics(vehicleLeaseDTO);
//			objResult = new ObjResult(CommonCode.SUCCESS);
//			if (Optional.ofNullable(reportReturnVO).isPresent()){
//				PageData pd = new PageData();
//				pd.put("grids", reportReturnVO.getGrids());
//				objResult.setPageData(pd);
//			}
//
//		}catch (Exception e) {
//			log.error(ExceptionUtils.getFullStackTrace(e));
//			objResult = new ObjResult(CommonCode.ERROR);
//			return objResult;
//		}
//		return objResult;
//	}
//
//	/**
//	 * 退租 车辆租赁管理
//	 */
//	@PostMapping("/output")
//	public R output(@RequestBody VehicleLease vehicleLease) {
//		return vehicleLeaseService.output(vehicleLease.getId()) ? new R(CommonCode.SUCCESS) : new R(CommonCode.FAIL);
//	}
//
//}
